package sp

import(
	"github.com/maxwellhealth/bongo"
	"www2/util"
	"gopkg.in/mgo.v2"
	"time"
)
type Category struct{
	ID int
	Name string
	Link string
	CType int
}
var ShtmlBongo = util.Bconn.Collection("shtml")
var ShtmlMgo *mgo.Collection  =util.Mconn.C("shtml")
var SImgBongo = util.Bconn.Collection("simg")
var SImgMgo *mgo.Collection  =util.Mconn.C("simg")

var DocBongo = util.Bconn.Collection("doc")
var DocMgo *mgo.Collection  =util.Mconn.C("doc")
//source Html
type Shtml struct{
	//bongo.AfterFindHook
	bongo.DocumentBase  `bson:",inline"`
	FUrl string // FUrl 完整url
	LM string //最后修改时间
	CT string //content-type
	Content string //内容
}
//func (s *ModelStruct) AfterFind(*bongo.Collection) error
//AfterFind(*Collection) error
//func (doc *Shtml)AfterFind(co *bongo.Collection) error{
//	log.Println(" shtml AfterFind")
//	if doc.CT==""{
//		doc.CT="text/html; charset=utf-8"
//	}
//	return nil
//}
func (h *Shtml) AfterFind(c *bongo.Collection) error {
	if h.CT == "" {
		h.CT = "text/html; charset=utf-8"
	}
	return nil
}
type SImg struct{
	bongo.DocumentBase  `bson:",inline"`
	FUrl string // FUrl 完整url
	LM string //最后修改时间
	CT string //content-type
	Content []byte //内容
}
type Doc struct{
	bongo.DocumentBase  `bson:",inline"`
	FUrl string // FUrl 完整url
	//Domain  string  //域名
	//Path string //绝对路径

	LM string //最后修改时间
	CT string "-"//content-type

	Content string //内容
	Title string
	Des string
}

func (doc *Doc) AfterFind(c *bongo.Collection) error{
	if doc.CT==""{
		doc.CT="text/html; charset=utf-8"
	}
	doc.Title+=" 官方文档 quickdoc"
	doc.Des+=" 国内快速访问 官方文档 quickdoc"

	if doc.LM==""{
		doc.LM=doc.DocumentBase.Modified.Format(time.RFC1123)
	}
	return nil
}



//currunt  domain

const (
	CD_mdn ="mdn"
	CD_es ="es"
	CD_redis ="redis"
	CD_rediscn ="rediscn"
	CD_mongodb="mongo"
	CD_w3="w3"
)
var CDALL []string=[]string{CD_mdn,CD_es,CD_redis,CD_rediscn,CD_mongodb,CD_w3}

var DomainMap map[string]string =map[string]string{
	CD_mdn:"https://developer.mozilla.org",
	CD_es:"https://www.elastic.co",
	CD_redis:"http://redis.io",	// http://redis.io/commands
	CD_rediscn:"http://redisdoc.com",
	CD_mongodb:"https://docs.mongodb.com", //https://docs.mongodb.com/manual/
	CD_w3:"http://www.w3schools.com", //https://docs.mongodb.com/manual/
}





type City struct {
	ID int
	CityId int
	CityName string
	ProvinceId string
	Sub Sub
	Testint int
}
type Sub struct{
//	ID int
	Test_value string
	CityID int `gorm:"column:tid"`
}

func (c Sub) TableName() string {
	return "dt_city_sub"
}
func (c City) TableName() string {
	return "dt_city"
}

type Patient struct{
	ID int
	Patient_user_name string
	Gender int
	Birthday string
	Tel_number string
	Health_insurance_type int
	Create_time int64
	PatientDep []PatientDep
}
func (c Patient) TableName() string {
	return "pr_patient_basic_info"
}
type PatientDep struct{
	Patient_id int
	Hospital_dept_id int
}
func (c PatientDep) TableName() string {
	return "pr_patient_hospital_dept_rel"
}

//type TmpMh struct {
//	ID int `gorm:"column:mhid"`
//
//	Zy []Zy
//	ZyInfo []Zy
//	ZyLesion []ZyLesion
//
//	//	MhDoctor []MhDoctor
//	//	Diagnose []Diagnose
//	//	CKBlood []CKBlood
//	//	CKBiochemical []CKBiochemical
//	//	CKGluose []CKGluose
//	//	CKMyocardial []CKMyocardial
//}
//func (c TmpMh) TableName() string {
//	return "mhs"
//}

type Mh struct {
	ID int

	Zy []Zy
	ZyInfo []ZyInfo
	ZyLesion []ZyLesion
	Pci []Pci
	Pci_vessel []Pci_vessel


	Admission_date string
	Discharge_date string
	PatientID string `gorm:"column:patient_user_id"`
	Is_smoke string
	Smoke_age string
	Smoke_number_perday  int
	Left_diastolic_pressure string
	Left_systolic_pressure string
	Heart_rate string
	Height string
	Weight string
	Bmi string
	Other_examin string
	Create_time string
	Disease_time string
	Hospital_dept_id string
	Chronic_heart_failure string
	Killip string
	Cardiac_shock string

	Diagnose []Diagnose
	MhDoctor []MhDoctor
	CKBlood []CKBlood
	CKBiochemical []CKBiochemical
	CKGlucose []CKGlucose
	CKMyocardial []CKMyocardial
	Quit_smoking_year int
	Admission_number string
}
func (c Mh) TableName() string {
	return "pr_patient_medical_history"
}

type Diagnose struct{
	Type string
	Diagnose_id string
	Other string
	Create_time string
	MhID int `gorm:"column:medical_history_id"`
}
func (c Diagnose) TableName() string {
	return "pr_patient_diagnose"
}

type  MhDoctor struct{
MhID int `gorm:"column:medical_history_id"`
Doctor_id int
Type  int
Sycnh_period int
}

func (c MhDoctor) TableName() string {
	return "pr_history_doctor_rel"
}


type CKBlood struct{
	MhID int `gorm:"column:medical_history_id"`
	White_cell float32
	Hemoglobin string
	Platelet string
	Hematocrit float32

}
func (c CKBlood) TableName() string {
	return "pr_check_blood"
}

type CKBiochemical struct{
	MhID int `gorm:"column:medical_history_id"`
	Total_cholesterol float32
	High_density_lipoprotein_cholesterol float32
	Low_density_lipoprotein_cholesterol float32
	Triglycerides float32
	Creatinine float32
	Sodium float32
	Potassium float32
	High_sensitivity_c_reactive_protein  float32
	CreatineKinase float32
	Alanine_aminotransferase float32
	Aspartate_aminotransferase float32
	TotalBilirubin float32
//	total_bilirubin
}
func (c CKBiochemical) TableName() string {
	return "pr_check_biochemical_check"
}

type CKGlucose struct{
	MhID int `gorm:"column:medical_history_id"`
	Hba1c string
}
func (c CKGlucose) TableName() string {
	return "pr_check_blood_glucose"
}

type CKMyocardial struct{
	MhID int `gorm:"column:medical_history_id"`
	Tni string
	Ckmb string
}
func (c CKMyocardial) TableName() string {
	return "pr_check_myocardial_enzymes"
}

type CKEquipment struct{
	MhID int `gorm:"column:medical_history_id"`
	St_change int
	Preoperative_cta int
	Exercise_test int
}
func (c CKEquipment) TableName() string {
	return "pr_check_equipment_inspection"
}


type Zy struct {
	Artery_edge string
	Mtifunction_catheter_model string
	Coronary_distribution string
	Angiographic_diagnos string
	MhID int `gorm:"column:medical_history_id"`

}
func(c Zy) TableName() string{
	return "pr_coronary_angiography"
}

type ZyInfo struct {
	Anesthesia_method string
	Intubation_and_approach int
	Intraoperative_medication string
	Intraoperative_unit string
	In_medicine_dosage string
	Contrast_agent_category string
	Contrast_dosage string
	Fluoroscopic_time string
	MhID int `gorm:"column:medical_history_id"`

}
func(c ZyInfo) TableName() string{
	return "pr_coronary_angiography_basic_info"
}

type ZyLesion struct {
	Coronary_artery_lesion string
	Lesions string
	Dilated_lesions_or_aneurysm string
	Spasm string
	Is_bridge string
	Lesion_morphology string
	Percent_stenosis string
	MhID int `gorm:"column:medical_history_id"`

}
func(c ZyLesion) TableName() string{
	return "pr_coronary_artery_lesion"
}

type Pci struct {
	Is_sycnh_period int
	Onset_time int64
	Admission_date int
	Admission_way int
	Balloon_ectasy_time int
	Anesthesia_method int
	Intubation_methods_approach int
	Puncture_site_treatment int
	MhID int `gorm:"column:medical_history_id"`
	PciOptions []PciOption
}
func(c Pci) TableName() string{
	return "pr_pci_basic_info"
}

type PciOption struct {
	ID int
	TypeID int  //1用药 2 穿刺
	DicID int  `gorm:"column:dictionary_id"`
	PciID int `gorm:"column:basic_id"`
}
func(c PciOption) TableName() string{
	return "pr_pci_basic_info_rel"
}


type Pci_vessel struct {
	ID int
	Target_vessel int
	Label int
	Start_time int64
	MhID int64 `gorm:"column:medical_history_id"`
	PciBalloon []PciBalloon
	Pci_stent []Pci_stent
	Pci_catheter []Pci_catheter
	Pci_guidwire []Pci_guidwire
}
func(c Pci_vessel) TableName() string{
	return "pr_target_vessel"
}
//func(c *PciVessel) AfterFind()  (err error){
//	c.ID=0
//	return
//}

type PciBalloon struct {
	Pci_vesselID  int `gorm:"column:target_vessel_id"`
	Balloon_id int
	Diameter float32
	Length float32
	Atm float32
	Secondary float32
	Second float32
	Medical_history_id int
	Remark string
}
func(c PciBalloon) TableName() string{
	return "pr_target_balloon"
}
type Pci_stent struct {
	Pci_vesselID  int `gorm:"column:target_vessel_id"`
	Bracket_id int
	Length float32
	Diameter float32
	Atm int
	Secondary int
	Second int
	Medical_history_id int
}
func(c Pci_stent) TableName() string{
	return "pr_target_stent_patients"

}
type Pci_catheter struct {
	Pci_vesselID  int `gorm:"column:target_vessel_id"`
	Catheter_id int
	French int
	The_time int
	Medical_history_id int

}
func(c Pci_catheter) TableName() string{
	return "pr_target_vessel_catheter"

}
type Pci_guidwire struct {
	Pci_vesselID  int `gorm:"column:target_vessel_id"`
	Guidewire_id int
	The_time int
	Remark string
	Medical_history_id int

}
func(c Pci_guidwire) TableName() string{
	return "pr_target_vessel_guidewire"

}



